package com.prolestar.web.controller.report;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.domain.entity.SysUser;
import com.prolestar.common.utils.SecurityUtils;
import com.prolestar.statistics.req.StaticsIndexReq;
import com.prolestar.statistics.res.IndustryStatisticsRes;
import com.prolestar.statistics.res.PublicOpinionStatisticsRes;
import com.prolestar.statistics.res.StatisticsOfPublicOpinion7DaysRes;
import com.prolestar.statistics.res.StatisticsOfPublicOpinionSourcesRes;
import com.prolestar.statistics.res.TerritorialStatisticsOfPublicOpinionRes;
import com.prolestar.statistics.service.IStatisticsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "舆情统计")
@RestController
@RequestMapping("/report/statistics")
public class StatisticsController extends BaseController {
	@Autowired
	private IStatisticsService statisticsService;
	 /**
     * 舆情统计
     *
     * @param req
     * @return
     */
    @ApiOperation(value = "舆情统计")
    @PostMapping(value = "/publicOpinionStatistics")
    public AjaxResult publicOpinionStatistics() {
        List<PublicOpinionStatisticsRes> res = statisticsService.publicOpinionStatistics();
        return success(res);

    }

    /**
     * 舆情来源统计
     *
     * @param req
     * @return
     */
    @ApiOperation(value = "舆情来源统计")
    @PostMapping(value = "/statisticsOfPublicOpinionSources")
    public AjaxResult statisticsOfPublicOpinionSources() {
        List<StatisticsOfPublicOpinionSourcesRes> res = statisticsService.statisticsOfPublicOpinionSources();
        return success(res);
    }
    
    @ApiOperation(value = "舆情七日统计")
    @PostMapping(value = "/statisticsOfPublicOpinion7Days")
    public AjaxResult statisticsOfPublicOpinion7Days() {
        List<StatisticsOfPublicOpinion7DaysRes> res = statisticsService.statisticsOfPublicOpinion7Days();
        return success(res);
    }

    /**
     * 舆情属地统计
     *
     * @param req
     * @return
     */
    @ApiOperation(value = "舆情属地统计")
    @PostMapping(value = "/territorialStatisticsOfPublicOpinion")
    public AjaxResult territorialStatisticsOfPublicOpinion() {
        List<TerritorialStatisticsOfPublicOpinionRes> res = statisticsService.territorialStatisticsOfPublicOpinion();
        return success(res);
    }

    /**
     * 行业领域统计
     *
     * @param req
     * @return
     */
    @ApiOperation(value = "行业领域统计")
    @PostMapping(value = "/industryStatistics")
    public AjaxResult industryStatistics() {
        List<IndustryStatisticsRes> res = statisticsService.industryStatistics();
        return success(res);
    }
    
    @ApiOperation(value = "舆情数量统计")
    @PostMapping(value = "/statics")
	public AjaxResult statics(@RequestBody StaticsIndexReq bean){
    	SysUser user = SecurityUtils.getLoginUser().getUser();
		return success(statisticsService.statics(bean));
	}
}
